package com.sws.web.controller.student_attendance.device;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sws.common.annotation.Log;
import com.sws.common.core.controller.BaseController;
import com.sws.common.core.domain.AjaxResult;
import com.sws.common.enums.BusinessType;
import com.sws.device.domain.DevDevice;
import com.sws.device.service.IDevDeviceService;
import com.sws.common.utils.poi.ExcelUtil;
import com.sws.common.core.page.TableDataInfo;

/**
 * 设备信息Controller
 * 
 * @author ruoyi
 * @date 2025-06-12
 */
@Api(tags = {"设备信息Controller"})
@RestController
@RequestMapping("/student/device/device")
public class DevDeviceController extends BaseController
{
    @Autowired
    private IDevDeviceService devDeviceService;

    /**
     * 查询设备信息列表
     */
    @ApiOperation("查询设备信息列表")
    @PreAuthorize("@ss.hasPermi('device:device:list')")
    @GetMapping("/list")
    public TableDataInfo list(DevDevice devDevice)
    {
        startPage();
        List<DevDevice> list = devDeviceService.selectDevDeviceList(devDevice);
        return getDataTable(list);
    }

    /**
     * 导出设备信息列表
     */
    @ApiOperation("导出设备信息列表")
    @PreAuthorize("@ss.hasPermi('device:device:export')")
    @Log(title = "设备信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DevDevice devDevice)
    {
        List<DevDevice> list = devDeviceService.selectDevDeviceList(devDevice);
        ExcelUtil<DevDevice> util = new ExcelUtil<DevDevice>(DevDevice.class);
        util.exportExcel(response, list, "设备信息数据");
    }

    /**
     * 获取设备信息详细信息
     */
    @ApiOperation("获取设备信息详细信息")
    @PreAuthorize("@ss.hasPermi('device:device:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(devDeviceService.selectDevDeviceById(id));
    }

    /**
     * 新增设备信息
     */
    @ApiOperation("新增设备信息")
    @PreAuthorize("@ss.hasPermi('device:device:add')")
    @Log(title = "设备信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DevDevice devDevice)
    {
        return toAjax(devDeviceService.insertDevDevice(devDevice));
    }

    /**
     * 修改设备信息
     */
    @ApiOperation("修改设备信息")
    @PreAuthorize("@ss.hasPermi('device:device:edit')")
    @Log(title = "设备信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DevDevice devDevice)
    {
        return toAjax(devDeviceService.updateDevDevice(devDevice));
    }

    /**
     * 删除设备信息
     */
    @ApiOperation("删除设备信息")
    @PreAuthorize("@ss.hasPermi('device:device:remove')")
    @Log(title = "设备信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(devDeviceService.deleteDevDeviceByIds(ids));
    }
}
